package cn.itcast.haa.tool;

import com.alibaba.cloud.ai.toolcalling.toutiaonews.ToutiaoNewsSearchHotEventsService;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 头条新闻查询工具
 *
 * @Author mr.wu
 * @Date 2025-11-7 15:31
 */
@Component
public class ToutiaoTool {

    @Autowired
    private ToutiaoNewsSearchHotEventsService toutiaoNewsSearchHotEventsService;

    @Tool(description = "查询今日头条热门新闻")
    public List<ToutiaoNewsSearchHotEventsService.HotEvent> getToutiaoNews(){
        ToutiaoNewsSearchHotEventsService.Response response = toutiaoNewsSearchHotEventsService.apply(new ToutiaoNewsSearchHotEventsService.Request());
        List<ToutiaoNewsSearchHotEventsService.HotEvent> hotEventList = response.events();
        return hotEventList;
    }
}
